package com.deepplin.mongodbmanager.util;

import java.util.StringTokenizer;

public class MongoDBUtil {

	public String makeQuery( String strQuery){
		
		return null;
	}
	
	/**
	 * 호스트 명을 확인
	 * @param strHost
	 * @return
	 */
	public static boolean checkHOST( String strHost){
		if( strHost.equals("localhost") | strHost.equals("LOCALHOST")){
			return true;
		}
		
		StringTokenizer st = new StringTokenizer(strHost , ".");
		String temp = null;
		if( st.countTokens() == 4)
		{
			while( st.hasMoreElements()){
				temp = st.nextToken();
				try {
					Integer.parseInt( temp);					
				} catch (java.lang.NumberFormatException e) {
					return false;
				}				
			}
			return true;
		}
		else{
			return false;
		}
	}
	
	/**
	 * 포트번호 확인
	 * @param strPORT
	 * @return
	 */
	public static boolean checkPORT( String strPORT){
		try {
			Integer.parseInt(strPORT);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
}
